<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改设备信息')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form class="form-horizontal" id="form-user-edit" th:object="${device}">
        <h4 class="form-header h4">设备信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">设备id：</label>
                    <div class="col-sm-8">
                        <input name="device_id"th:field="*{device_id}" readonly placeholder="请输入设备id" class="form-control" type="text" maxlength="30" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">设备名称：</label>
                    <div class="col-sm-8">
                        <input name="device_name"th:field="*{device_name}" id="warehouse_id" type="text" placeholder="请选择归属部门" class="form-control"required>
                    </div>
                </div>
            </div>
        </div><div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label is-required">设备类型：</label>
                <div class="col-sm-8">
                    <input name="device_type" th:field="*{device_type}" placeholder="请输巷道区id" class="form-control" type="text" maxlength="30" required>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">保养周期：</label>
                <div class="col-sm-8">
                    <input name="maintenance_cycle" th:field="*{maintenance_cycle}" id="cargo_area_id" type="text" placeholder="请选择归属部门" class="form-control">
                </div>
            </div>
        </div>
    </div><div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label ">保养范围：</label>
                <div class="col-sm-8">
                    <input name="maintenance_range"th:field="*{maintenance_range}" placeholder="请输入货位类型" class="form-control" type="text" maxlength="30" >
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">是否锁定：</label>
                <div class="col-sm-8">
                    <label class="toggle-switch switch-solid">
                        <input type="checkbox" id="locked"  th:checked="${locked == 'Y' ? 1 : 0}">
                        <span></span>
                    </label>
                </div>
            </div>
        </div>
    </div>
    </form>
</div>
<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存
        </button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭
        </button>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script type="text/javascript">
    var prefix = ctx + "device/basDevice";


    function submitHandler() {
        if ($.validate.form()) {
        	var data = $("#form-user-edit").serializeArray();
        	var locked = $("input[id='locked']").is(':checked') == true ? "Y" : "N";
        	data.push({"name": "locked", "value": locked});
        	$.operate.saveTab(prefix + "/edit", data);
        }
    }
</script>
</body>
</html>